package cn.yqm.frame.template;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

public class FormPack {
	
	public static FormTemplate reflexPack(String beanClass,HttpServletRequest request){
		FormTemplate form = null;
		if(beanClass != null){
			try {
				Class bean = Class.forName(beanClass);
				form = (FormTemplate)bean.newInstance();
				
				//注入属性值
				Field[] fields = bean.getDeclaredFields();
				for (Field field : fields) {
					field.setAccessible(true);
					field.set(form, request.getParameter(field.getName()));
					field.setAccessible(false);
				}
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return form;
	}
}
